from venya.lib import exception
from venya.lib import ip
from venya.lib import stdlib
from venya.lib.trie import Node

class PrefixList(Node):
   def __init__(self, Value):
      super(PrefixList, self).__init__(Value)
      self._networks = []
      self._description = None

   def AddNetworks(self, *args):
      for ix in args:
         self._networks.append(ix)

   def AddDescr(self, Descr = ""):
      self._description = str(Descr)

   def __str__(self):
      return str(self.value)

class RouteMap(Node):
   def __init__(self, Value):
      super(RouteMap, self).__init__(Value)
      self._pref = 100
      self._pfl = []
      self._aspath = []

   def AddPrefixList(self, PrefixList):
      if PrefixList:
         self._pfl.append(PrefixList)

   def AddAsPath(self, AsNumber):
      if AsNumber:
         self._aspath.append(stdlib.asdot2num(AsNumber))

   def AddLocalPref(self, Pref):
      self._pref = int(Pref)

   def AddDescr(self, Descr = ""):
      self._description = str(Descr)

   def __str__(self):
      return str(self.value)
